//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>
package org.jpgolay.gui.fixed;

import java.awt.*;
import javax.swing.*;

public class LabelAndDateButton extends JPanel {

    public LabelAndDateButton() {
        jLabel = null;
        jButtonRight = null;
        jPanel = null;
        icon = null;
        initialize();
    }

    private void initialize() {
        setLayout(new BorderLayout());
        setSize(306, 27);
        add(getJPanel(), "Center");
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            jPanel = new JPanel();
            FlowLayout flowLayout8 = new FlowLayout();
            jPanel.setLayout(flowLayout8);
            flowLayout8.setHgap(2);
            flowLayout8.setVgap(2);
            jPanel.add(getJLabel(), null);
            jPanel.add(getJButtonRight(), null);
        }
        return jPanel;
    }

    private JLabel getJLabel() {
        if (jLabel == null) {
            jLabel = new JLabel();
            jLabel.setText("N/A");
            jLabel.setPreferredSize(new Dimension(277, 23));
        }
        return jLabel;
    }

    private JButton getJButtonRight() {
        if (jButtonRight == null) {
            jButtonRight = new JButton();
            jButtonRight.setIcon(getIcon());
            jButtonRight.setPreferredSize(new Dimension(23, 23));
            jButtonRight.setBorderPainted(false);
            jButtonRight.setContentAreaFilled(false);
            jButtonRight.setToolTipText("S\351l\351ctionner une p\351riode");
        }
        return jButtonRight;
    }

    private Icon getIcon() {
        if (icon == null) {
            icon = new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/sch.png"));
        }
        return icon;
    }

    public void setIconButton(Icon icon) {
        this.icon = icon;
        getJButtonRight().setIcon(icon);
    }

    public void setToolTipTextButton(String txt) {
        getJButtonRight().setToolTipText(txt);
    }

    public void setLabelLeft(String label) {
        getJLabel().setText(label);
    }

    public String getLabelLeft() {
        return getJLabel().getText();
    }

    public void setButtonLabelRight(String label) {
        getJButtonRight().setText(label);
    }

    public String getButtonLabelRight() {
        return getJButtonRight().getText();
    }

    public JButton getButtonRight() {
        return getJButtonRight();
    }
    private JLabel jLabel;
    private JButton jButtonRight;
    private JPanel jPanel;
    private Icon icon;
}
